<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta content="" name="keywords">

  <title> Ubuntu 安装 Docker CE - </title>
  <meta name="description" content="" />
  <meta property="og:title" content="Ubuntu 安装 Docker CE" />
  <meta name="twitter:title" content="Ubuntu 安装 Docker CE" />
  <meta name="description" content="警告：切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.">
  <meta property="og:description" content="警告：切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.">
  <meta name="twitter:description" content="警告：切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.">
  <meta name="author" content="{Description { .Site.Author.name }}"/>
  <meta name="twitter:card" content="summary" />
  <meta property="og:url" content="https://systemime.github.io/blog/2019-02/ubuntu-%E5%AE%89%E8%A3%85-docker-ce/" />
  <meta property="og:type" content="website" />
  <meta property="og:site_name" content="听风的小站" />

  <meta name="generator" content="Hugo 0.67.0" />
  <link rel="canonical" href="https://systemime.github.io/blog/2019-02/ubuntu-%E5%AE%89%E8%A3%85-docker-ce/" />
  <link rel="alternate" href="https://systemime.github.io/index.xml" type="application/rss+xml" title="听风的小站">
  <script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/jquery-1.12.4.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  
  
  <link rel="stylesheet" href="https://systemime.github.io/css/main.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/my.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pace.css" />
  <link rel="stylesheet" href="https://cdn.plyr.io/3.4.7/plyr.css">
  <link rel="stylesheet" href="https://systemime.github.io/css/lightgallery.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/baguetteBox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/search.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/reward.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/share.min.css" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pygment_highlights.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/highlight.min.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/toc.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/lightbox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/live2d/css/live2d.css" />
  
  <link href="https://systemime.github.io/css/video-js.css" rel="stylesheet">


<meta name="baidu-site-verification" content="g8IYR9SNLF" />
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cffe439e37449bb1c07ab26ab56484bb";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<link rel="stylesheet" href="https://systemime.github.io/css/prism.css" />









<script src="https://systemime.github.io/js/pace.min.js" data-no-instant></script>



<script src="https://systemime.github.io/js/instantclick.min.js" data-no-instant></script>
   <script data-no-instant>
   InstantClick.on('change', function(isInitialLoad) {
     if (isInitialLoad === false) {
       if (typeof MathJax !== 'undefined') 
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
       if (typeof prettyPrint !== 'undefined') 
         prettyPrint();
       if (typeof _hmt !== 'undefined')  
         _hmt.push(['_trackPageview', location.pathname + location.search]);
       if (typeof ga !== 'undefined')  
           ga('send', 'pageview', location.pathname + location.search);
     }
   });
   InstantClick.init();
</script>




<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.7.1/gist-embed.min.js"></script>


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-3925981084585036",
    enable_page_level_ads: true
  });
</script>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.css" integrity="sha256-sCl5PUOGMLfFYctzDW3MtRib0ctyUvI9Qsmq2wXOeBY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/default-skin/default-skin.min.css" integrity="sha256-BFeI1V+Vh1Rk37wswuOYn5lsTcaU96hGaI7OUVCLjPc=" crossorigin="anonymous" />



<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

<div class="pswp__bg"></div>

<div class="pswp__scroll-wrap">
    
    <div class="pswp__container">
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
    </div>
    
    <div class="pswp__ui pswp__ui--hidden">
    <div class="pswp__top-bar">
      
      <div class="pswp__counter"></div>
      <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
      <button class="pswp__button pswp__button--share" title="Share"></button>
      <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
      <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
      
      
      <div class="pswp__preloader">
        <div class="pswp__preloader__icn">
          <div class="pswp__preloader__cut">
            <div class="pswp__preloader__donut"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
      <div class="pswp__share-tooltip"></div>
    </div>
    <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
    </button>
    <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
    </button>
    <div class="pswp__caption">
      <div class="pswp__caption__center"></div>
    </div>
    </div>
    </div>
</div>

</head>

  <body>
    <nav class="navbar navbar-default navbar-fixed-top navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://systemime.github.io">听风的小站</a>
    </div>
    <div class="collapse navbar-collapse" id="main-navbar">
      <ul class="nav navbar-nav navbar-right">
        
          
            <li>
		    <a title="博客" href="https://systemime.github.io/blog/">博客</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="片刻" href="https://systemime.github.io/moment/">片刻</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="关于" href="https://systemime.github.io/about/">关于</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="留言" href="https://systemime.github.io/message/">留言</a>
              
              
            </li>
          
        

        

        
        
      </ul>
    </div>

    <div class="avatar-container">
      <div class="avatar-img-border">
        
      </div>
    </div>

  </div>
</nav>






    
  
  
  




  

  <header class="header-section ">
    
    <div class="intro-header no-img">
      
      <div class="container">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-md-offset-0">
            <div class="blog-heading">
                <h1 align="center">Ubuntu 安装 Docker CE</h1>
                
                
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>


    
<div class="container" role="main" itemscope itemtype="http://schema.org/Article">
    <div class="row">
        <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
            
            
            
<div>
    <section id="datecount">
        <h4 id="date"> Tue Feb 12, 2019</h4>
    </section>
    <h5 id="wc">2600 Words|Read in about 6 Min|本文总阅读量<span id="busuanzi_value_page_pv"></span>次</h5>
    <h5 id="tags">Tags: 
        
        <a href="https://systemime.github.iotags/docker/">Docker</a> &nbsp;
        
        <a href="https://systemime.github.iotags/%E5%AE%89%E8%A3%85/">安装</a> &nbsp;
    </h5>
</div>

            
            <article role="main" class="blog-post" itemprop="articleBody" id="content">
                
<aside class="toc">
    <div id='anchors-navbar'>
        <i class='fa fa-anchor'></i>
        <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#系统要求">系统要求</a></li>
        <li><a href="#卸载旧版本">卸载旧版本</a></li>
        <li><a href="#ubuntu-1404-可选内核模块">Ubuntu 14.04 可选内核模块</a></li>
      </ul>
    </li>
    <li><a href="#ubuntu-1604-">Ubuntu 16.04 +</a>
      <ul>
        <li><a href="#使用-apt-安装">使用 APT 安装</a></li>
        <li><a href="#安装-docker-ce">安装 Docker CE</a></li>
        <li><a href="#使用脚本自动安装">使用脚本自动安装</a></li>
      </ul>
    </li>
    <li><a href="#centos7安装docker-ce">centos7安装Docker CE</a>
      <ul>
        <li><a href="#系统要求-1">系统要求</a></li>
        <li><a href="#卸载旧版本-1">卸载旧版本</a></li>
        <li><a href="#安装docker-ce">安装Docker CE</a></li>
      </ul>
    </li>
    <li><a href="#启动-docker-ce">启动 Docker CE</a></li>
    <li><a href="#卸载docker">卸载Docker</a></li>
    <li><a href="#建立-docker-用户组">建立 docker 用户组</a></li>
    <li><a href="#测试-docker-是否安装正确">测试 Docker 是否安装正确</a></li>
    <li><a href="#镜像加速">镜像加速</a></li>
    <li><a href="#ubuntu-1404debian-7-wheezy">Ubuntu 14.04、Debian 7 Wheezy</a></li>
    <li><a href="#ubuntu-1604debian-8centos-7">Ubuntu 16.04+、Debian 8+、CentOS 7</a></li>
    <li><a href="#windows-10">Windows 10</a></li>
    <li><a href="#macos">macOS</a></li>
    <li><a href="#检查加速器是否生效">检查加速器是否生效</a></li>
  </ul>
</nav>
    </div>
    
</aside>


                <h1 id="ubuntu-安装-docker-ce">Ubuntu 安装 Docker CE</h1>
<blockquote>
<p>警告：切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.</p>
</blockquote>
<h3 id="系统要求">系统要求</h3>
<p>Docker CE 支持以下版本的 Ubuntu 操作系统：</p>
<ul>
<li>Bionic 18.04 (LTS)</li>
<li>Xenial 16.04 (LTS)</li>
<li>Trusty 14.04 (LTS) (Docker CE v18.06 及以下版本)</li>
</ul>
<p>Docker CE 可以安装在 64 位的 x86 平台或 ARM 平台上。Ubuntu 发行版中，LTS（Long-Term-Support）长期支持版本，会获得 5 年的升级维护支持，这样的版本会更稳定，因此在生产环境中推荐使用 LTS 版本。</p>
<h3 id="卸载旧版本">卸载旧版本</h3>
<p>旧版本的 Docker 称为<strong><code>docker</code></strong>或者<strong><code>docker-engine</code></strong>，使用以下命令卸载旧版本：</p>
<pre><code>$ sudo apt-get remove docker \
               docker-engine \
               docker.io
</code></pre><h3 id="ubuntu-1404-可选内核模块">Ubuntu 14.04 可选内核模块</h3>
<p>从 Ubuntu 14.04 开始，一部分内核模块移到了可选内核模块包 (<strong><code>linux-image-extra-*</code></strong>) ，以减少内核软件包的体积。正常安装的系统应该会包含可选内核模块包，而一些裁剪后的系统可能会将其精简掉。<strong><code>AUFS</code></strong>内核驱动属于可选内核模块的一部分，作为推荐的 Docker 存储层驱动，一般建议安装可选内核模块包以使用<strong><code>AUFS</code></strong>。
如果系统没有安装可选内核模块的话，可以执行下面的命令来安装可选内核模块包：</p>
<pre><code>$ sudo apt-get update

$ sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual
</code></pre><h2 id="ubuntu-1604-">Ubuntu 16.04 +</h2>
<p>Ubuntu 16.04 + 上的 Docker CE 默认使用 overlay2 存储层驱动,无需手动配置。</p>
<h3 id="使用-apt-安装">使用 APT 安装</h3>
<p>由于<strong><code>apt</code></strong>源使用 HTTPS 以确保软件下载过程中不被篡改。因此，我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。</p>
<pre><code>$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
</code></pre><p>鉴于国内网络问题，强烈建议使用国内源，官方源请在注释中查看。</p>
<p>为了确认所下载软件包的合法性，需要添加软件源的<strong><code>GPG</code></strong>密钥。</p>
<pre><code>$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -


# 官方源
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
</code></pre><p>然后，我们需要向<strong><code>source.list</code></strong>中添加 Docker 软件源</p>
<pre><code>$ sudo add-apt-repository \
    &quot;deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
    $(lsb_release -cs) \
    stable&quot;


# 官方源
# $ sudo add-apt-repository \
#    &quot;deb [arch=amd64] https://download.docker.com/linux/ubuntu \
#    $(lsb_release -cs) \
#    stable&quot;
</code></pre><blockquote>
<p>以上命令会添加稳定版本的 Docker CE APT 镜像源，如果需要测试或每日构建版本的 Docker CE 请将 stable 改为 test 或者 nightly。</p>
</blockquote>
<h3 id="安装-docker-ce">安装 Docker CE</h3>
<p>更新 apt 软件包缓存，并安装<strong><code>docker-ce</code></strong>：</p>
<pre><code>$ sudo apt-get update

$ sudo apt-get install docker-ce
</code></pre><h3 id="使用脚本自动安装">使用脚本自动安装</h3>
<p>在测试或开发环境中 Docker 官方为了简化安装流程，提供了一套便捷的安装脚本，Ubuntu 系统上可以使用这套脚本安装：</p>
<pre><code>$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
</code></pre><p>执行这个命令后，脚本就会自动的将一切准备工作做好，并且把 Docker CE 的 Edge 版本安装在系统中。</p>
<h2 id="centos7安装docker-ce">centos7安装Docker CE</h2>
<ul>
<li><a href="https://docs.docker.com/install/linux/docker-ce/centos/">官方文档</a><a href="https://docs.docker.com/install/linux/docker-ce/centos/">https://docs.docker.com/install/linux/docker-ce/centos/</a></li>
</ul>
<h3 id="系统要求-1">系统要求</h3>
<p>1、安装Docker CE，需要一个维护版本的Centos7</p>
<p>2、centos-extras库必须启用，这个存储库默认启用，但是如果您禁用了它，您需要重新启用它（<a href="https://wiki.centos.org/AdditionalResources/Repositories">https://wiki.centos.org/AdditionalResources/Repositories</a>）</p>
<h3 id="卸载旧版本-1">卸载旧版本</h3>
<pre><code>yum remove docker docker-common docker-selinux
</code></pre><h3 id="安装docker-ce">安装Docker CE</h3>
<ol>
<li>使用仓库安装</li>
</ol>
<ul>
<li>安装需要的依赖包</li>
</ul>
<pre><code>yum install -y yum-utils device-mapper-persistent-data
</code></pre><ul>
<li>配置稳定仓库</li>
</ul>
<pre><code>yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
</code></pre><ul>
<li>安装</li>
</ul>
<pre><code>yum install docker-ce
</code></pre><ul>
<li>安装指定版本的Docker</li>
</ul>
<div class="highlight"><pre class="chroma"><code class="language-go" data-lang="go"><span class="p">[</span><span class="nx">root</span><span class="err">@</span><span class="nx">docker</span> <span class="err">~</span><span class="p">]</span><span class="err">#</span> <span class="nx">yum</span> <span class="nx">list</span> <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span> <span class="o">--</span><span class="nx">showduplicates</span> <span class="p">|</span> <span class="nx">sort</span> <span class="o">-</span><span class="nx">r</span>
 <span class="o">*</span> <span class="nx">updates</span><span class="p">:</span> <span class="nx">mirrors</span><span class="p">.</span><span class="nx">aliyun</span><span class="p">.</span><span class="nx">com</span>
<span class="nx">Loading</span> <span class="nx">mirror</span> <span class="nx">speeds</span> <span class="nx">from</span> <span class="nx">cached</span> <span class="nx">hostfile</span>
<span class="nx">Loaded</span> <span class="nx">plugins</span><span class="p">:</span> <span class="nx">fastestmirror</span>
<span class="nx">Installed</span> <span class="nx">Packages</span>
 <span class="o">*</span> <span class="nx">extras</span><span class="p">:</span> <span class="nx">mirrors</span><span class="p">.</span><span class="nx">aliyun</span><span class="p">.</span><span class="nx">com</span>
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.09.0</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.09.0</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="err">@</span><span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span>
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.06.2</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.06.1</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.06.0</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.03.2</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.03.1</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
<span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="p">.</span><span class="nx">x86_64</span>            <span class="mf">17.03.0</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span>            <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="nx">stable</span> 
 <span class="o">*</span> <span class="nx">base</span><span class="p">:</span> <span class="nx">mirrors</span><span class="p">.</span><span class="nx">aliyun</span><span class="p">.</span><span class="nx">com</span>
<span class="nx">Available</span> <span class="nx">Packages</span>

<span class="p">[</span><span class="nx">root</span><span class="err">@</span><span class="nx">docker</span> <span class="err">~</span><span class="p">]</span><span class="err">#</span> <span class="nx">yum</span> <span class="nx">install</span> <span class="nx">docker</span><span class="o">-</span><span class="nx">ce</span><span class="o">-</span><span class="mf">17.06.0</span><span class="p">.</span><span class="nx">ce</span><span class="o">-</span><span class="mf">1.</span><span class="nx">el7</span><span class="p">.</span><span class="nx">centos</span><span class="p">.</span><span class="nx">x86_64</span>
</code></pre></div><ol start="2">
<li>使用rpm包安装docker</li>
</ol>
<ul>
<li>
<p>稳定版下载地址：
<a href="https://download.docker.com/linux/centos/7/x86_64/stable/Packages/">https://download.docker.com/linux/centos/7/x86_64/stable/Packages/</a></p>
</li>
<li>
<p>安装</p>
</li>
</ul>
<pre><code>yum install -y /path/to/package.rpm
</code></pre><ul>
<li>启动</li>
</ul>
<pre><code>systemctl start docker
</code></pre><ul>
<li>版本升级</li>
</ul>
<pre><code>yum -y upgrade  /path/to/package.rpm
</code></pre><ol start="3">
<li>使用已有脚本安装</li>
</ol>
<pre><code>curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
</code></pre><ol start="4">
<li>配置Docker开机自启动</li>
</ol>
<pre><code>systemctl enable docker
</code></pre><h2 id="启动-docker-ce">启动 Docker CE</h2>
<pre><code>$ sudo systemctl enable docker
$ sudo systemctl start docker
</code></pre><p>Ubuntu 14.04 请使用以下命令启动：</p>
<pre><code>$ sudo service docker start
</code></pre><h2 id="卸载docker">卸载Docker</h2>
<ul>
<li>卸载docker-ce</li>
</ul>
<pre><code>yum remove docker-ce
</code></pre><ul>
<li>在您的主机上的镜像、容器、卷或自定义配置文件不会自动删除，要删除所有图像、容器和卷:</li>
</ul>
<pre><code>rm -rf /var/lib/docker
</code></pre><h2 id="建立-docker-用户组">建立 docker 用户组</h2>
<p>默认情况下，<strong><code>docker</code></strong>命令会使用<a href="https://en.wikipedia.org/wiki/Unix_domain_socket"> Unix socket </a>与 Docker 引擎通讯。而只有<strong><code>root</code></strong>用户和<strong><code>docker</code></strong>组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑，一般 Linux 系统上不会直接使用<strong><code>root</code></strong>用户。因此，更好地做法是将需要使用<strong><code>docker</code></strong>的用户加入<strong><code>docker</code></strong>用户组。</p>
<p>建立<strong><code>docker</code></strong>组：</p>
<pre><code>$ sudo groupadd docker
</code></pre><p>将当前用户加入<strong><code>docker</code></strong>组：</p>
<pre><code>$ sudo usermod -aG docker $USER
</code></pre><p>退出当前终端并重新登录，进行如下测试。</p>
<h2 id="测试-docker-是否安装正确">测试 Docker 是否安装正确</h2>
<pre><code>$ docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
</code></pre><p>若能正常输出以上信息，则说明安装成功。</p>
<p>** 参考 ** <a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">Docker 官方 Ubuntu 安装文档</a></p>
<h2 id="镜像加速">镜像加速</h2>
<p>如果在使用过程中发现拉取 Docker 镜像十分缓慢，可以配置 Docker 国内镜像加速。</p>
<p>国内从 Docker Hub 拉取镜像有时会遇到困难，此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务，例如：</p>
<ul>
<li><a href="https://docs.docker.com/registry/recipes/mirror/#use-case-the-china-registry-mirror">Docker 官方提供的中国 registry mirror <code>https://registry.docker-cn.com</code></a></li>
<li><a href="https://cr.console.aliyun.com/cn-hangzhou/mirrors">阿里云加速器(需登录账号获取)</a></li>
<li><a href="https://kirk-enterprise.github.io/hub-docs/#/user-guide/mirror">七牛云加速器 <code>https://reg-mirror.qiniu.com/</code></a></li>
</ul>
<blockquote>
<p>当配置某一个加速器地址之后，若发现拉取不到镜像，请切换到另一个加速器地址。</p>
<p>国内各大云服务商均提供了 Docker 镜像加速服务，建议根据运行 Docker 的云平台选择对应的镜像加速服务。</p>
</blockquote>
<p>我们以 Docker 官方加速器 <code>https://registry.docker-cn.com</code> 为例进行介绍。</p>
<h2 id="ubuntu-1404debian-7-wheezy">Ubuntu 14.04、Debian 7 Wheezy</h2>
<p>对于使用 <code>upstart</code> 的系统而言，编辑 <code>/etc/default/docker</code> 文件，在其中的 <code>DOCKER_OPTS</code> 中配置加速器地址：</p>
<pre><code>DOCKER_OPTS=&quot;--registry-mirror=https://registry.docker-cn.com&quot;
</code></pre><p>重新启动服务。</p>
<pre><code>$ sudo service docker restart
</code></pre><h2 id="ubuntu-1604debian-8centos-7">Ubuntu 16.04+、Debian 8+、CentOS 7</h2>
<p>对于使用 systemd 的系统，请在 <code>/etc/docker/daemon.json</code> 中写入如下内容（如果文件不存在请新建该文件）</p>
<pre><code>{
  &quot;registry-mirrors&quot;: [
    &quot;https://registry.docker-cn.com&quot;
  ]
}
</code></pre><blockquote>
<p>注意，一定要保证该文件符合 json 规范，否则 Docker 将不能启动。</p>
</blockquote>
<p>之后重新启动服务。</p>
<pre><code>$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
</code></pre><blockquote>
<p>注意：如果您之前查看旧教程，修改了 docker.service 文件内容，请去掉您添加的内容（&ndash;registry-mirror=https://registry.docker-cn.com），这里不再赘述。</p>
</blockquote>
<h2 id="windows-10">Windows 10</h2>
<p>对于使用 Windows 10 的系统，在系统右下角托盘 Docker 图标内右键菜单选择 <code>Settings</code>，打开配置窗口后左侧导航菜单选择 <code>Daemon</code>。在 <code>Registry mirrors</code> 一栏中填写加速器地址 <code>https://registry.docker-cn.com</code>，之后点击 <code>Apply</code> 保存后 Docker 就会重启并应用配置的镜像地址了。</p>
<h2 id="macos">macOS</h2>
<p>对于使用 macOS 的用户，在任务栏点击 Docker for mac 应用图标 -&gt; Perferences&hellip; -&gt; Daemon -&gt; Registry mirrors。在列表中填写加速器地址 <code>https://registry.docker-cn.com</code>。修改完成之后，点击 <code>Apply &amp; Restart</code> 按钮，Docker 就会重启并应用配置的镜像地址了。</p>
<h2 id="检查加速器是否生效">检查加速器是否生效</h2>
<p>命令行执行 <code>docker info</code>，如果从结果中看到了如下内容，说明配置成功。</p>
<pre><code>Registry Mirrors:
 https://registry.docker-cn.com/
</code></pre>
                <br />
                <div style="text-align:center;color: #ccc;font-size:16px;font-family: cursive;">-------他日江湖相逢 <i class="fa fa-umbrella"></i> 再当杯酒言欢-------</div>
                <script src="https://systemime.github.io/js/particle.js"></script>
                
                
                <div class="social-share" data-initialized="true" data-wechat-qrcode-title="不扫别后悔">
    <center>
    <font style="font-size:18px;color:darkcyan;">分享到：</font>
    <a href="#" class="social-share-icon icon-weibo"></a>
    <a href="#" class="social-share-icon icon-wechat"></a>
    <a href="#" class="social-share-icon icon-twitter"></a>
    <a href="#" class="social-share-icon icon-linkedin"></a>
    <a href="#" class="social-share-icon icon-facebook"></a>
    <a href="#" class="social-share-icon icon-qq"></a>
    </center>
</div>


<script src="https://hugo-picture.oss-cn-beijing.aliyuncs.com/social-share.min.js"></script>

                
            </article>

            <ul class="pager blog-pager">
                
                <li class="previous">
                    <a href="https://systemime.github.io/blog/2019-02/golang%E4%B9%8Bnil/" data-toggle="tooltip" data-placement="top" title="Golang之nil">&larr; Previous Post</a>
                </li>
                 
                <li class="next">
                    <a href="https://systemime.github.io/blog/2019-02/%E4%BD%BF%E7%94%A8-dockerfile-%E5%AE%9A%E5%88%B6%E9%95%9C%E5%83%8F/" data-toggle="tooltip" data-placement="top" title="使用 Dockerfile 定制镜像">Next Post &rarr;</a>
                </li>
                
            </ul>
            
            <div>
                 
                <h2>相关文章</h2>
                <ul>
                    
                    <li><a href="https://systemime.github.io/blog/2019-01/windows%E5%AE%89%E8%A3%85neo4j%E6%95%B0%E6%8D%AE%E5%BA%93/">windows安装Neo4j数据库</a></li>
                    
                    <li><a href="https://systemime.github.io/blog/2019-01/win10%E5%AE%89%E8%A3%85maven3.3/">WIN10安装Maven3.3</a></li>
                    
                    <li><a href="https://systemime.github.io/blog/2019-01/docker%E5%85%A5%E9%97%A8/">Docker入门</a></li>
                    
                </ul>
                
            </div>
            
            
            
              
            
            </div>
        </div>
        <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
            
            
        </div>
    </div>
    </section>
</div>

    <div class="rocket"><img src="https://systemime.github.io/img/rocket_up.png" alt="" width="100" height="100"></div>
<script>
    $(function () {
      $(window).scroll(function () {
        
        if ($(window).scrollTop() >= 1000) {
          $('.rocket').stop().fadeIn(1000);
        }else {
          $('.rocket').stop().fadeOut(1000);
        }
      })
      
      $('.rocket').click(function () {
        $('html,body').stop().animate({scrollTop:0},400);
       
      })
    })

</script>

    
    <div id="landlord">
        <div class="message" style="opacity:0"></div>
        <canvas id="live2d" width="280" height="250" class="live2d"></canvas>
        <div class="hide-button">隐藏</div>
    </div>
    
    <footer id="copyright">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <ul class="list-inline text-center footer-links">
          
          
        </ul>
        <p class="credits copyright text-muted">
        &copy;2017-2018
          
          &nbsp;&bull;&nbsp;
          September 20,2019
          updated
          
            &nbsp;&bull;&nbsp;
            <a href="https://systemime.github.io">Home</a>
          
        </p>

        <p class="credits theme-by text-muted">
        <a href="https://servicemesher.github.io" target="_blank">ServiceMesher</a>&nbsp;&bull;&nbsp;<a href="https://github.com/yangchuansheng/k8s-knowledge" target="_blank">Kubernetes 知识图谱</a>
        <br />
        <span id="busuanzi_container_site_pv">
            本站已被访问 <span id="busuanzi_value_site_pv"></span> 次啦
        </span>
        <span id="busuanzi_container_site_uv">
            &ensp;|&ensp;&thinsp;您是第 <span id="busuanzi_value_site_uv"></span> 位到访的小伙伴喔
        </span>
        </p>
        
        <p class="credits theme-by text-muted">
          <a href="http://gohugo.io">Hugo v0.67.0</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>
          
          <center><section class="credits theme-by text-muted">
    <span class="footer__copyright">
    <div>
    <span id="span_dt_dt"> </span>
    <script language="javascript">
      function show_date_time(){
        window.setTimeout("show_date_time()", 1000);
        BirthDay=new Date("7/8/2017 10:56:12");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML="本博客已经开心运行 "+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分 "+seconds+" 秒";
      }
      show_date_time();
    </script>
    </div>
</script>
</section>
</center>
        </p>
      </div>
    </div>
  </div>
</footer>


<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/bootstrap.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe-ui-default.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/auto-render.min.js"></script>
<script src="https://systemime.github.io/js/main.js"></script>
<script src="https://systemime.github.io/js/clipboard.min.js"></script>
<script src="https://systemime.github.io/js/prism.js?t=123"></script>
<script src="https://systemime.github.io/js/highlight.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/katex.min.js"></script>
<script src="https://systemime.github.io/js/reward.js"></script>
<script src="https://systemime.github.io/js/canvas_ribbon.js"></script>
<script> renderMathInElement(document.body); </script>

<script src="https://systemime.github.io/js/baguetteBox.js"></script>
<script> baguetteBox.run('.gallery');</script>






<script async defer src="https://buttons.github.io/buttons.js"></script>


<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
<script type="text/javascript" src="https://systemime.github.io/js/quicklink.umd.js"></script>
<script>
window.addEventListener('load', () =>{
   quicklink();
});
</script>



<script type="text/javascript">
 
var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("Docker", "Kubernetes", "Prometheus", "Envoy", "Istio", "Service Mesh", "Cloud Native");
        var $i = $("<span />").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        function randomColor() {
          var flakeColor = new Array("#FFDA65", "#00BFFF", "#BA55D3", "#FFA07A", "#87CEEB", "#FFB6C1");
          var snowColor = flakeColor[Math.floor(flakeColor.length * Math.random())];
          return snowColor;
        }
        $i.css({
            "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": randomColor()
        });
        $("body").append($i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});
</script>


<script type="text/javascript" src="https://systemime.github.io/js/lightbox.js"></script>











<script src="https://cdn.plyr.io/3.4.7/plyr.js"></script>
<script>const player = new Plyr('#player');</script>


<script async defer src="https://buttons.github.io/buttons.js"></script>


  </body>
</html>

